/*
  This file is part of jTopaz.
  http://gcl.cis.udel.edu/projects/jtopaz
  Copyright (C) 2009 University of Delaware

  jTopaz is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  jTopaz is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of                                                        
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with jTopaz.  If not, see <http://www.gnu.org/licenses/>.
*/

package jTopaz;

import org.globus.ftp.GridFTPClient;
import org.globus.ftp.FTPClient;

public class ListThread extends Thread {
	
    private boolean complete = false;
    private GridFTPClient client;
    private FTPClient AnonClient;
    private String destDir;
    private Object[] contents;
    private String status;
	
    public ListThread(GridFTPClient client) {
	this.client = client;
    }
    public ListThread(FTPClient client){
	this.AnonClient = client;
    }
	
    public void run() {
	try {
	    //client.changeDir(destDir);
	    if(client!=null){
		contents = client.mlsd().toArray();
	    }
	    else{
		contents = AnonClient.mlsd().toArray();
	    }
	    complete = true;
	    status = "success";	
	}
	catch (Exception e) {
	    complete = true;
	    status = e.toString();
	}
    }
	
    public boolean listComplete() {
	return complete;
    }
	
    public String getStatus() {
	return status;	
    }
	
    public Object[] getContents() {
	return contents;	
    }	
}